/**
 */
package BlipTGG.Rules.impl;

import BlipLanguage.BlipApplication;
import BlipLanguage.BlipLanguageFactory;
import BlipLanguage.BlipModel;
import BlipLanguage.BlipModelAttribute;

import BlipTGG.BlipTGGFactory;
import BlipTGG.MApplicationToApplication;
import BlipTGG.MModelAttributeToModelAttribute;
import BlipTGG.MModelToModel;

import BlipTGG.Rules.MModelToModelRule;
import BlipTGG.Rules.RulesPackage;

import MocaTree.Attribute;
import MocaTree.MocaTreeFactory;
import MocaTree.Node;

import TGGLanguage.csp.*;

import TGGRuntime.Edge;
import TGGRuntime.IsApplicableMatch;
import TGGRuntime.IsApplicableRuleResult;
import TGGRuntime.IsAppropriateRuleResult;
import TGGRuntime.Match;
import TGGRuntime.PerformRuleResult;
import TGGRuntime.TGGRuntimeFactory;

import TGGRuntime.impl.AbstractRuleImpl;

import csp.constraints.*;

import de.upb.tools.sdm.*;

import java.lang.reflect.InvocationTargetException;

import java.util.*;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>MModel To Model Rule</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class MModelToModelRuleImpl extends AbstractRuleImpl implements
		MModelToModelRule {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MModelToModelRuleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return RulesPackage.Literals.MMODEL_TO_MODEL_RULE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PerformRuleResult perform_FWD(IsApplicableMatch isApplicableMatch) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		BlipApplication application = null;
		Node applicationNode = null;
		Node blipModelNode = null;
		MApplicationToApplication mApplicationToApplication = null;
		Attribute nameAttr = null;
		Iterator fujaba__IterIsApplicableMatchToCsp = null;
		CSP csp = null;
		MModelToModel mModelToModel = null;
		BlipModel blipModel = null;
		PerformRuleResult ruleresult = null;
		Edge mModelToModel__source__blipModelNode = null;
		Edge mModelToModel__target__blipModel = null;
		Edge application__models__blipModel = null;
		Edge blipModelNode__attribute__nameAttr = null;
		Edge blipModelNode__parentNode__applicationNode = null;

		// story node 'perform transformation'
		try {
			fujaba__Success = false;

			_TmpObject = (isApplicableMatch.getObject("application"));

			// ensure correct type and really bound of object application
			JavaSDM.ensure(_TmpObject instanceof BlipApplication);
			application = (BlipApplication) _TmpObject;
			_TmpObject = (isApplicableMatch.getObject("applicationNode"));

			// ensure correct type and really bound of object applicationNode
			JavaSDM.ensure(_TmpObject instanceof Node);
			applicationNode = (Node) _TmpObject;
			_TmpObject = (isApplicableMatch.getObject("blipModelNode"));

			// ensure correct type and really bound of object blipModelNode
			JavaSDM.ensure(_TmpObject instanceof Node);
			blipModelNode = (Node) _TmpObject;
			_TmpObject = (isApplicableMatch
					.getObject("mApplicationToApplication"));

			// ensure correct type and really bound of object mApplicationToApplication
			JavaSDM.ensure(_TmpObject instanceof MApplicationToApplication);
			mApplicationToApplication = (MApplicationToApplication) _TmpObject;
			_TmpObject = (isApplicableMatch.getObject("nameAttr"));

			// ensure correct type and really bound of object nameAttr
			JavaSDM.ensure(_TmpObject instanceof Attribute);
			nameAttr = (Attribute) _TmpObject;
			// check object isApplicableMatch is really bound
			JavaSDM.ensure(isApplicableMatch != null);
			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// iterate to-many link attributeInfo from isApplicableMatch to csp
			fujaba__Success = false;

			fujaba__IterIsApplicableMatchToCsp = isApplicableMatch
					.getAttributeInfo().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterIsApplicableMatchToCsp.hasNext()) {
				try {
					_TmpObject = fujaba__IterIsApplicableMatchToCsp.next();

					// ensure correct type and really bound of object csp
					JavaSDM.ensure(_TmpObject instanceof CSP);
					csp = (CSP) _TmpObject;

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			if (!fujaba__Success) {
				fujaba__Success = true;
				csp = null;
			}
			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(blipModelNode.getName(),
					"Model") == 0);

			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(nameAttr.getName(), "name") == 0);

			// create object mModelToModel
			mModelToModel = BlipTGGFactory.eINSTANCE.createMModelToModel();

			// create object blipModel
			blipModel = BlipLanguageFactory.eINSTANCE.createBlipModel();

			// assign attribute blipModel
			blipModel.setName((java.lang.String) csp.getAttributeVariable(
					"blipModel", "name").getValue());

			// create link
			mModelToModel.setSource(blipModelNode);

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(mModelToModel,
					blipModel, "target");

			// create link
			application.getModels().add(blipModel); // add link

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'collect translated elements'
		try {
			fujaba__Success = false;

			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object mModelToModel is really bound
			JavaSDM.ensure(mModelToModel != null);
			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE.createPerformRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(true);

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModel, "createdElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					nameAttr, "translatedElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode, "translatedElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel, "createdLinkElements");
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'bookkeeping for edges'
		try {
			fujaba__Success = false;

			// check object application is really bound
			JavaSDM.ensure(application != null);
			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);
			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object mApplicationToApplication is really bound
			JavaSDM.ensure(mApplicationToApplication != null);
			// check object mModelToModel is really bound
			JavaSDM.ensure(mModelToModel != null);
			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// check isomorphic binding between objects applicationNode and application 
			JavaSDM.ensure(!applicationNode.equals(application));

			// check isomorphic binding between objects blipModel and application 
			JavaSDM.ensure(!blipModel.equals(application));

			// check isomorphic binding between objects blipModelNode and application 
			JavaSDM.ensure(!blipModelNode.equals(application));

			// check isomorphic binding between objects mApplicationToApplication and application 
			JavaSDM.ensure(!mApplicationToApplication.equals(application));

			// check isomorphic binding between objects mModelToModel and application 
			JavaSDM.ensure(!mModelToModel.equals(application));

			// check isomorphic binding between objects nameAttr and application 
			JavaSDM.ensure(!nameAttr.equals(application));

			// check isomorphic binding between objects blipModel and applicationNode 
			JavaSDM.ensure(!blipModel.equals(applicationNode));

			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// check isomorphic binding between objects mApplicationToApplication and applicationNode 
			JavaSDM.ensure(!mApplicationToApplication.equals(applicationNode));

			// check isomorphic binding between objects mModelToModel and applicationNode 
			JavaSDM.ensure(!mModelToModel.equals(applicationNode));

			// check isomorphic binding between objects nameAttr and applicationNode 
			JavaSDM.ensure(!nameAttr.equals(applicationNode));

			// check isomorphic binding between objects blipModelNode and blipModel 
			JavaSDM.ensure(!blipModelNode.equals(blipModel));

			// check isomorphic binding between objects mApplicationToApplication and blipModel 
			JavaSDM.ensure(!mApplicationToApplication.equals(blipModel));

			// check isomorphic binding between objects mModelToModel and blipModel 
			JavaSDM.ensure(!mModelToModel.equals(blipModel));

			// check isomorphic binding between objects nameAttr and blipModel 
			JavaSDM.ensure(!nameAttr.equals(blipModel));

			// check isomorphic binding between objects mApplicationToApplication and blipModelNode 
			JavaSDM.ensure(!mApplicationToApplication.equals(blipModelNode));

			// check isomorphic binding between objects mModelToModel and blipModelNode 
			JavaSDM.ensure(!mModelToModel.equals(blipModelNode));

			// check isomorphic binding between objects nameAttr and blipModelNode 
			JavaSDM.ensure(!nameAttr.equals(blipModelNode));

			// check isomorphic binding between objects mModelToModel and mApplicationToApplication 
			JavaSDM.ensure(!mModelToModel.equals(mApplicationToApplication));

			// check isomorphic binding between objects nameAttr and mApplicationToApplication 
			JavaSDM.ensure(!nameAttr.equals(mApplicationToApplication));

			// check isomorphic binding between objects nameAttr and mModelToModel 
			JavaSDM.ensure(!nameAttr.equals(mModelToModel));

			// create object mModelToModel__source__blipModelNode
			mModelToModel__source__blipModelNode = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object mModelToModel__target__blipModel
			mModelToModel__target__blipModel = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object application__models__blipModel
			application__models__blipModel = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object blipModelNode__attribute__nameAttr
			blipModelNode__attribute__nameAttr = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object blipModelNode__parentNode__applicationNode
			blipModelNode__parentNode__applicationNode = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// assign attribute blipModelNode__parentNode__applicationNode
			blipModelNode__parentNode__applicationNode.setName("parentNode");
			// assign attribute blipModelNode__attribute__nameAttr
			blipModelNode__attribute__nameAttr.setName("attribute");
			// assign attribute mModelToModel__source__blipModelNode
			mModelToModel__source__blipModelNode.setName("source");
			// assign attribute mModelToModel__target__blipModel
			mModelToModel__target__blipModel.setName("target");
			// assign attribute application__models__blipModel
			application__models__blipModel.setName("models");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel__source__blipModelNode, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel__target__blipModel, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					application__models__blipModel, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode__attribute__nameAttr, "translatedEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode__parentNode__applicationNode,
					"translatedEdges");

			// create link
			blipModelNode__parentNode__applicationNode.setTrg(applicationNode);

			// create link
			blipModelNode__attribute__nameAttr.setSrc(blipModelNode);

			// create link
			mModelToModel__source__blipModelNode.setTrg(blipModelNode);

			// create link
			blipModelNode__parentNode__applicationNode.setSrc(blipModelNode);

			// create link
			blipModelNode__attribute__nameAttr.setTrg(nameAttr);

			// create link
			mModelToModel__target__blipModel.setSrc(mModelToModel);

			// create link
			mModelToModel__source__blipModelNode.setSrc(mModelToModel);

			// create link
			application__models__blipModel.setSrc(application);

			// create link
			mModelToModel__target__blipModel.setTrg(blipModel);

			// create link
			application__models__blipModel.setTrg(blipModel);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// statement node 'perform postprocessing'
		// No post processing method found
		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isAppropriate_FWD(Match match, Node applicationNode,
			Node blipModelNode, Attribute nameAttr) {
		boolean fujaba__Success = false;
		Edge blipModelNode__parentNode__applicationNode = null;
		Edge blipModelNode__attribute__nameAttr = null;

		// statement node 'Solve CSP'
		// Create CSP
		CSP csp = CspFactory.eINSTANCE.createCSP();

		// Create literals

		// Create attribute variables

		// Create explicit parameters

		// Create unbound variables

		// Create constraints

		// Solve CSP

		// statement node 'Check CSP'
		fujaba__Success = csp.check();
		if (fujaba__Success) {
			// story node 'collect elements to be translated'
			try {
				fujaba__Success = false;

				// check object applicationNode is really bound
				JavaSDM.ensure(applicationNode != null);
				// check object blipModelNode is really bound
				JavaSDM.ensure(blipModelNode != null);
				// check object match is really bound
				JavaSDM.ensure(match != null);
				// check object nameAttr is really bound
				JavaSDM.ensure(nameAttr != null);
				// check isomorphic binding between objects blipModelNode and applicationNode 
				JavaSDM.ensure(!blipModelNode.equals(applicationNode));

				// create object blipModelNode__parentNode__applicationNode
				blipModelNode__parentNode__applicationNode = TGGRuntimeFactory.eINSTANCE
						.createEdge();

				// create object blipModelNode__attribute__nameAttr
				blipModelNode__attribute__nameAttr = TGGRuntimeFactory.eINSTANCE
						.createEdge();

				// assign attribute blipModelNode__parentNode__applicationNode
				blipModelNode__parentNode__applicationNode
						.setName("parentNode");
				// assign attribute blipModelNode__attribute__nameAttr
				blipModelNode__attribute__nameAttr.setName("attribute");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						nameAttr, "toBeTranslatedElements");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						blipModelNode__parentNode__applicationNode,
						"toBeTranslatedEdges");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						blipModelNode__attribute__nameAttr,
						"toBeTranslatedEdges");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						blipModelNode, "toBeTranslatedElements");

				// create link
				blipModelNode__attribute__nameAttr.setSrc(blipModelNode);

				// create link
				blipModelNode__parentNode__applicationNode
						.setSrc(blipModelNode);

				// create link
				blipModelNode__attribute__nameAttr.setTrg(nameAttr);

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(
						blipModelNode__parentNode__applicationNode,
						applicationNode, "trg");
				fujaba__Success = true;
			} catch (JavaSDMException fujaba__InternalException) {
				fujaba__Success = false;
			}

			// story node 'collect context elements'
			try {
				fujaba__Success = false;

				// check object applicationNode is really bound
				JavaSDM.ensure(applicationNode != null);
				// check object match is really bound
				JavaSDM.ensure(match != null);

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						applicationNode, "contextNodes");
				fujaba__Success = true;
			} catch (JavaSDMException fujaba__InternalException) {
				fujaba__Success = false;
			}

			// statement node 'register objects to match'
			match.registerObject("applicationNode", applicationNode);
			match.registerObject("blipModelNode", blipModelNode);
			match.registerObject("nameAttr", nameAttr);

			return true;

		} else {
			return false;

		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsApplicableRuleResult isApplicable_FWD(Match match) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsApplicableRuleResult ruleresult = null;
		Node applicationNode = null;
		Node blipModelNode = null;
		Attribute nameAttr = null;
		IsApplicableMatch isApplicableMatch = null;
		BlipApplication application = null;
		Iterator fujaba__IterApplicationNodeToMApplicationToApplication = null;
		MApplicationToApplication mApplicationToApplication = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "perform_FWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsApplicableRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);
			// assign attribute ruleresult
			ruleresult.setRule("MModelToModelRule");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					performOperation, "performOperation");
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'core match'
		try {
			fujaba__Success = false;

			_TmpObject = (match.getObject("applicationNode"));

			// ensure correct type and really bound of object applicationNode
			JavaSDM.ensure(_TmpObject instanceof Node);
			applicationNode = (Node) _TmpObject;
			_TmpObject = (match.getObject("blipModelNode"));

			// ensure correct type and really bound of object blipModelNode
			JavaSDM.ensure(_TmpObject instanceof Node);
			blipModelNode = (Node) _TmpObject;
			_TmpObject = (match.getObject("nameAttr"));

			// ensure correct type and really bound of object nameAttr
			JavaSDM.ensure(_TmpObject instanceof Attribute);
			nameAttr = (Attribute) _TmpObject;
			// check object match is really bound
			JavaSDM.ensure(match != null);
			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(blipModelNode.getName(),
					"Model") == 0);

			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(nameAttr.getName(), "name") == 0);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'find context'
		try {
			fujaba__Success = false;

			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);
			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// check link attribute from nameAttr to blipModelNode
			JavaSDM.ensure(blipModelNode.equals(nameAttr.getNode()));

			// check link children from blipModelNode to applicationNode
			JavaSDM.ensure(applicationNode.equals(blipModelNode.getParentNode()));

			// iterate to-many link source from applicationNode to mApplicationToApplication
			fujaba__Success = false;

			fujaba__IterApplicationNodeToMApplicationToApplication = new ArrayList(
					org.moflon.util.eMoflonEMFUtil.getOppositeReference(
							applicationNode, MApplicationToApplication.class,
							"source")).iterator();

			while (fujaba__IterApplicationNodeToMApplicationToApplication
					.hasNext()) {
				try {
					mApplicationToApplication = (MApplicationToApplication) fujaba__IterApplicationNodeToMApplicationToApplication
							.next();

					// check object mApplicationToApplication is really bound
					JavaSDM.ensure(mApplicationToApplication != null);
					// bind object
					application = mApplicationToApplication.getTarget();

					// check object application is really bound
					JavaSDM.ensure(application != null);

					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							blipModelNode.getName(), "Model") == 0);

					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(nameAttr.getName(),
							"name") == 0);

					// create object isApplicableMatch
					isApplicableMatch = TGGRuntimeFactory.eINSTANCE
							.createIsApplicableMatch();

					// statement node 'solve CSP'
					// Create CSP
					CSP csp = CspFactory.eINSTANCE.createCSP();
					isApplicableMatch.getAttributeInfo().add(csp);

					// Create literals

					// Create attribute variables
					Variable<String> var_nameAttr_value = CspFactory.eINSTANCE
							.createVariable("nameAttr.value", true, csp);
					var_nameAttr_value.setValue(nameAttr.getValue());

					// Create explicit parameters

					// Create unbound variables
					Variable<String> var_blipModel_name = CspFactory.eINSTANCE
							.createVariable("blipModel.name", csp);

					// Create constraints
					Eq<String> eq = new Eq<String>();

					csp.getConstraints().add(eq);

					// Solve CSP
					eq.setRuleName("");
					eq.solve(var_nameAttr_value, var_blipModel_name);

					// Snapshot pattern match on which CSP is solved
					isApplicableMatch.registerObject("applicationNode",
							applicationNode);
					isApplicableMatch.registerObject("blipModelNode",
							blipModelNode);
					isApplicableMatch.registerObject("nameAttr", nameAttr);
					isApplicableMatch.registerObject(
							"mApplicationToApplication",
							mApplicationToApplication);
					isApplicableMatch
							.registerObject("application", application);

					// statement node 'check CSP'
					fujaba__Success = csp.check();
					if (fujaba__Success) {
						// story node 'add match to rule result'
						try {
							fujaba__Success = false;

							// check object isApplicableMatch is really bound
							JavaSDM.ensure(isApplicableMatch != null);
							// check object ruleresult is really bound
							JavaSDM.ensure(ruleresult != null);
							// assign attribute ruleresult
							ruleresult.setSuccess(true);

							// create link
							ruleresult.getIsApplicableMatch().add(
									isApplicableMatch);

							fujaba__Success = true;
						} catch (JavaSDMException fujaba__InternalException) {
							fujaba__Success = false;
						}

					} else {

					}

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PerformRuleResult perform_BWD(IsApplicableMatch isApplicableMatch) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		BlipApplication application = null;
		Node applicationNode = null;
		BlipModel blipModel = null;
		MApplicationToApplication mApplicationToApplication = null;
		Iterator fujaba__IterIsApplicableMatchToCsp = null;
		CSP csp = null;
		Node blipModelNode = null;
		Attribute nameAttr = null;
		MModelToModel mModelToModel = null;
		PerformRuleResult ruleresult = null;
		Edge blipModelNode__parentNode__applicationNode = null;
		Edge mModelToModel__target__blipModel = null;
		Edge blipModelNode__attribute__nameAttr = null;
		Edge application__models__blipModel = null;
		Edge mModelToModel__source__blipModelNode = null;

		// story node 'perform transformation'
		try {
			fujaba__Success = false;

			_TmpObject = (isApplicableMatch.getObject("application"));

			// ensure correct type and really bound of object application
			JavaSDM.ensure(_TmpObject instanceof BlipApplication);
			application = (BlipApplication) _TmpObject;
			_TmpObject = (isApplicableMatch.getObject("applicationNode"));

			// ensure correct type and really bound of object applicationNode
			JavaSDM.ensure(_TmpObject instanceof Node);
			applicationNode = (Node) _TmpObject;
			_TmpObject = (isApplicableMatch.getObject("blipModel"));

			// ensure correct type and really bound of object blipModel
			JavaSDM.ensure(_TmpObject instanceof BlipModel);
			blipModel = (BlipModel) _TmpObject;
			_TmpObject = (isApplicableMatch
					.getObject("mApplicationToApplication"));

			// ensure correct type and really bound of object mApplicationToApplication
			JavaSDM.ensure(_TmpObject instanceof MApplicationToApplication);
			mApplicationToApplication = (MApplicationToApplication) _TmpObject;
			// check object isApplicableMatch is really bound
			JavaSDM.ensure(isApplicableMatch != null);
			// iterate to-many link attributeInfo from isApplicableMatch to csp
			fujaba__Success = false;

			fujaba__IterIsApplicableMatchToCsp = isApplicableMatch
					.getAttributeInfo().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterIsApplicableMatchToCsp.hasNext()) {
				try {
					_TmpObject = fujaba__IterIsApplicableMatchToCsp.next();

					// ensure correct type and really bound of object csp
					JavaSDM.ensure(_TmpObject instanceof CSP);
					csp = (CSP) _TmpObject;

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			if (!fujaba__Success) {
				fujaba__Success = true;
				csp = null;
			}
			// create object blipModelNode
			blipModelNode = MocaTreeFactory.eINSTANCE.createNode();

			// create object nameAttr
			nameAttr = MocaTreeFactory.eINSTANCE.createAttribute();

			// create object mModelToModel
			mModelToModel = BlipTGGFactory.eINSTANCE.createMModelToModel();

			// assign attribute blipModelNode
			blipModelNode.setName("Model");
			// assign attribute nameAttr
			nameAttr.setName("name");
			// assign attribute nameAttr
			nameAttr.setValue((java.lang.String) csp.getAttributeVariable(
					"nameAttr", "value").getValue());

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(mModelToModel,
					blipModel, "target");

			// create link
			blipModelNode.setParentNode(applicationNode);

			// create link
			nameAttr.setNode(blipModelNode);

			// create link
			mModelToModel.setSource(blipModelNode);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'collect translated elements'
		try {
			fujaba__Success = false;

			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object mModelToModel is really bound
			JavaSDM.ensure(mModelToModel != null);
			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE.createPerformRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(true);

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel, "createdLinkElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					nameAttr, "createdElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode, "createdElements");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModel, "translatedElements");
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'bookkeeping for edges'
		try {
			fujaba__Success = false;

			// check object application is really bound
			JavaSDM.ensure(application != null);
			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);
			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object mApplicationToApplication is really bound
			JavaSDM.ensure(mApplicationToApplication != null);
			// check object mModelToModel is really bound
			JavaSDM.ensure(mModelToModel != null);
			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// check isomorphic binding between objects applicationNode and application 
			JavaSDM.ensure(!applicationNode.equals(application));

			// check isomorphic binding between objects blipModel and application 
			JavaSDM.ensure(!blipModel.equals(application));

			// check isomorphic binding between objects blipModelNode and application 
			JavaSDM.ensure(!blipModelNode.equals(application));

			// check isomorphic binding between objects mApplicationToApplication and application 
			JavaSDM.ensure(!mApplicationToApplication.equals(application));

			// check isomorphic binding between objects mModelToModel and application 
			JavaSDM.ensure(!mModelToModel.equals(application));

			// check isomorphic binding between objects nameAttr and application 
			JavaSDM.ensure(!nameAttr.equals(application));

			// check isomorphic binding between objects blipModel and applicationNode 
			JavaSDM.ensure(!blipModel.equals(applicationNode));

			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// check isomorphic binding between objects mApplicationToApplication and applicationNode 
			JavaSDM.ensure(!mApplicationToApplication.equals(applicationNode));

			// check isomorphic binding between objects mModelToModel and applicationNode 
			JavaSDM.ensure(!mModelToModel.equals(applicationNode));

			// check isomorphic binding between objects nameAttr and applicationNode 
			JavaSDM.ensure(!nameAttr.equals(applicationNode));

			// check isomorphic binding between objects blipModelNode and blipModel 
			JavaSDM.ensure(!blipModelNode.equals(blipModel));

			// check isomorphic binding between objects mApplicationToApplication and blipModel 
			JavaSDM.ensure(!mApplicationToApplication.equals(blipModel));

			// check isomorphic binding between objects mModelToModel and blipModel 
			JavaSDM.ensure(!mModelToModel.equals(blipModel));

			// check isomorphic binding between objects nameAttr and blipModel 
			JavaSDM.ensure(!nameAttr.equals(blipModel));

			// check isomorphic binding between objects mApplicationToApplication and blipModelNode 
			JavaSDM.ensure(!mApplicationToApplication.equals(blipModelNode));

			// check isomorphic binding between objects mModelToModel and blipModelNode 
			JavaSDM.ensure(!mModelToModel.equals(blipModelNode));

			// check isomorphic binding between objects nameAttr and blipModelNode 
			JavaSDM.ensure(!nameAttr.equals(blipModelNode));

			// check isomorphic binding between objects mModelToModel and mApplicationToApplication 
			JavaSDM.ensure(!mModelToModel.equals(mApplicationToApplication));

			// check isomorphic binding between objects nameAttr and mApplicationToApplication 
			JavaSDM.ensure(!nameAttr.equals(mApplicationToApplication));

			// check isomorphic binding between objects nameAttr and mModelToModel 
			JavaSDM.ensure(!nameAttr.equals(mModelToModel));

			// create object blipModelNode__parentNode__applicationNode
			blipModelNode__parentNode__applicationNode = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object mModelToModel__target__blipModel
			mModelToModel__target__blipModel = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object blipModelNode__attribute__nameAttr
			blipModelNode__attribute__nameAttr = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object application__models__blipModel
			application__models__blipModel = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// create object mModelToModel__source__blipModelNode
			mModelToModel__source__blipModelNode = TGGRuntimeFactory.eINSTANCE
					.createEdge();

			// assign attribute blipModelNode__parentNode__applicationNode
			blipModelNode__parentNode__applicationNode.setName("parentNode");
			// assign attribute blipModelNode__attribute__nameAttr
			blipModelNode__attribute__nameAttr.setName("attribute");
			// assign attribute mModelToModel__source__blipModelNode
			mModelToModel__source__blipModelNode.setName("source");
			// assign attribute mModelToModel__target__blipModel
			mModelToModel__target__blipModel.setName("target");
			// assign attribute application__models__blipModel
			application__models__blipModel.setName("models");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode__parentNode__applicationNode, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel__target__blipModel, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					blipModelNode__attribute__nameAttr, "createdEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					application__models__blipModel, "translatedEdges");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					mModelToModel__source__blipModelNode, "createdEdges");

			// create link
			blipModelNode__parentNode__applicationNode.setTrg(applicationNode);

			// create link
			mModelToModel__source__blipModelNode.setTrg(blipModelNode);

			// create link
			blipModelNode__parentNode__applicationNode.setSrc(blipModelNode);

			// create link
			blipModelNode__attribute__nameAttr.setSrc(blipModelNode);

			// create link
			blipModelNode__attribute__nameAttr.setTrg(nameAttr);

			// create link
			mModelToModel__source__blipModelNode.setSrc(mModelToModel);

			// create link
			mModelToModel__target__blipModel.setSrc(mModelToModel);

			// create link
			application__models__blipModel.setSrc(application);

			// create link
			mModelToModel__target__blipModel.setTrg(blipModel);

			// create link
			application__models__blipModel.setTrg(blipModel);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// statement node 'perform postprocessing'
		// No post processing method found
		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isAppropriate_BWD(Match match, BlipApplication application,
			BlipModel blipModel) {
		boolean fujaba__Success = false;
		Edge application__models__blipModel = null;

		// statement node 'Solve CSP'
		// Create CSP
		CSP csp = CspFactory.eINSTANCE.createCSP();

		// Create literals

		// Create attribute variables

		// Create explicit parameters

		// Create unbound variables

		// Create constraints

		// Solve CSP

		// statement node 'Check CSP'
		fujaba__Success = csp.check();
		if (fujaba__Success) {
			// story node 'collect elements to be translated'
			try {
				fujaba__Success = false;

				// check object application is really bound
				JavaSDM.ensure(application != null);
				// check object blipModel is really bound
				JavaSDM.ensure(blipModel != null);
				// check object match is really bound
				JavaSDM.ensure(match != null);
				// create object application__models__blipModel
				application__models__blipModel = TGGRuntimeFactory.eINSTANCE
						.createEdge();

				// assign attribute application__models__blipModel
				application__models__blipModel.setName("models");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						application__models__blipModel, "toBeTranslatedEdges");

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						blipModel, "toBeTranslatedElements");

				// create link
				application__models__blipModel.setTrg(blipModel);

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(
						application__models__blipModel, application, "src");
				fujaba__Success = true;
			} catch (JavaSDMException fujaba__InternalException) {
				fujaba__Success = false;
			}

			// story node 'collect context elements'
			try {
				fujaba__Success = false;

				// check object application is really bound
				JavaSDM.ensure(application != null);
				// check object match is really bound
				JavaSDM.ensure(match != null);

				// create link
				org.moflon.util.eMoflonEMFUtil.addOppositeReference(match,
						application, "contextNodes");
				fujaba__Success = true;
			} catch (JavaSDMException fujaba__InternalException) {
				fujaba__Success = false;
			}

			// statement node 'register objects to match'
			match.registerObject("application", application);
			match.registerObject("blipModel", blipModel);

			return true;

		} else {
			return false;

		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsApplicableRuleResult isApplicable_BWD(Match match) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsApplicableRuleResult ruleresult = null;
		BlipApplication application = null;
		BlipModel blipModel = null;
		IsApplicableMatch isApplicableMatch = null;
		Node applicationNode = null;
		Iterator fujaba__IterApplicationToMApplicationToApplication = null;
		MApplicationToApplication mApplicationToApplication = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "perform_BWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsApplicableRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);
			// assign attribute ruleresult
			ruleresult.setRule("MModelToModelRule");

			// create link
			org.moflon.util.eMoflonEMFUtil.addOppositeReference(ruleresult,
					performOperation, "performOperation");
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'core match'
		try {
			fujaba__Success = false;

			_TmpObject = (match.getObject("application"));

			// ensure correct type and really bound of object application
			JavaSDM.ensure(_TmpObject instanceof BlipApplication);
			application = (BlipApplication) _TmpObject;
			_TmpObject = (match.getObject("blipModel"));

			// ensure correct type and really bound of object blipModel
			JavaSDM.ensure(_TmpObject instanceof BlipModel);
			blipModel = (BlipModel) _TmpObject;
			// check object match is really bound
			JavaSDM.ensure(match != null);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'find context'
		try {
			fujaba__Success = false;

			// check object application is really bound
			JavaSDM.ensure(application != null);
			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check link models from blipModel to application
			JavaSDM.ensure(application.equals(blipModel.eContainer()));

			// iterate to-many link target from application to mApplicationToApplication
			fujaba__Success = false;

			fujaba__IterApplicationToMApplicationToApplication = new ArrayList(
					org.moflon.util.eMoflonEMFUtil.getOppositeReference(
							application, MApplicationToApplication.class,
							"target")).iterator();

			while (fujaba__IterApplicationToMApplicationToApplication.hasNext()) {
				try {
					mApplicationToApplication = (MApplicationToApplication) fujaba__IterApplicationToMApplicationToApplication
							.next();

					// check object mApplicationToApplication is really bound
					JavaSDM.ensure(mApplicationToApplication != null);
					// bind object
					applicationNode = mApplicationToApplication.getSource();

					// check object applicationNode is really bound
					JavaSDM.ensure(applicationNode != null);

					// create object isApplicableMatch
					isApplicableMatch = TGGRuntimeFactory.eINSTANCE
							.createIsApplicableMatch();

					// statement node 'solve CSP'
					// Create CSP
					CSP csp = CspFactory.eINSTANCE.createCSP();
					isApplicableMatch.getAttributeInfo().add(csp);

					// Create literals

					// Create attribute variables
					Variable<String> var_blipModel_name = CspFactory.eINSTANCE
							.createVariable("blipModel.name", true, csp);
					var_blipModel_name.setValue(blipModel.getName());

					// Create explicit parameters

					// Create unbound variables
					Variable<String> var_nameAttr_value = CspFactory.eINSTANCE
							.createVariable("nameAttr.value", csp);

					// Create constraints
					Eq<String> eq = new Eq<String>();

					csp.getConstraints().add(eq);

					// Solve CSP
					eq.setRuleName("");
					eq.solve(var_nameAttr_value, var_blipModel_name);

					// Snapshot pattern match on which CSP is solved
					isApplicableMatch.registerObject("applicationNode",
							applicationNode);
					isApplicableMatch.registerObject(
							"mApplicationToApplication",
							mApplicationToApplication);
					isApplicableMatch
							.registerObject("application", application);
					isApplicableMatch.registerObject("blipModel", blipModel);

					// statement node 'check CSP'
					fujaba__Success = csp.check();
					if (fujaba__Success) {
						// story node 'add match to rule result'
						try {
							fujaba__Success = false;

							// check object isApplicableMatch is really bound
							JavaSDM.ensure(isApplicableMatch != null);
							// check object ruleresult is really bound
							JavaSDM.ensure(ruleresult != null);
							// assign attribute ruleresult
							ruleresult.setSuccess(true);

							// create link
							ruleresult.getIsApplicableMatch().add(
									isApplicableMatch);

							fujaba__Success = true;
						} catch (JavaSDMException fujaba__InternalException) {
							fujaba__Success = false;
						}

					} else {

					}

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsAppropriateRuleResult isAppropriate_FWD_Node_3(Node applicationNode) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsAppropriateRuleResult ruleresult = null;
		Match match = null;
		Iterator fujaba__IterBlipModelNodeToNameAttr = null;
		Attribute nameAttr = null;
		Iterator fujaba__IterApplicationNodeToBlipModelNode = null;
		Node blipModelNode = null;
		Iterator fujaba__IterRuleresultToMatch = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "isApplicable_FWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsAppropriateRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);

			// create link
			ruleresult.setPerformOperation(performOperation);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'test core match'
		try {
			fujaba__Success = false;

			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link children from applicationNode to blipModelNode
			fujaba__Success = false;

			fujaba__IterApplicationNodeToBlipModelNode = new ArrayList(
					applicationNode.getChildren()).iterator();

			while (fujaba__IterApplicationNodeToBlipModelNode.hasNext()) {
				try {
					_TmpObject = fujaba__IterApplicationNodeToBlipModelNode
							.next();

					// ensure correct type and really bound of object blipModelNode
					JavaSDM.ensure(_TmpObject instanceof Node);
					blipModelNode = (Node) _TmpObject;
					// check isomorphic binding between objects blipModelNode and applicationNode 
					JavaSDM.ensure(!blipModelNode.equals(applicationNode));

					// iterate to-many link attribute from blipModelNode to nameAttr
					fujaba__Success = false;

					fujaba__IterBlipModelNodeToNameAttr = new ArrayList(
							blipModelNode.getAttribute()).iterator();

					while (fujaba__IterBlipModelNodeToNameAttr.hasNext()) {
						try {
							nameAttr = (Attribute) fujaba__IterBlipModelNodeToNameAttr
									.next();

							// check object nameAttr is really bound
							JavaSDM.ensure(nameAttr != null);
							// attribute condition
							JavaSDM.ensure(JavaSDM.stringCompare(
									blipModelNode.getName(), "Model") == 0);

							// attribute condition
							JavaSDM.ensure(JavaSDM.stringCompare(
									nameAttr.getName(), "name") == 0);

							// create object match
							match = TGGRuntimeFactory.eINSTANCE.createMatch();

							// statement node 'bookkeeping with generic isAppropriate method'
							fujaba__Success = this.isAppropriate_FWD(match,
									applicationNode, blipModelNode, nameAttr);
							if (fujaba__Success) {
								// story node 'Add match to rule result'
								try {
									fujaba__Success = false;

									// check object match is really bound
									JavaSDM.ensure(match != null);
									// check object ruleresult is really bound
									JavaSDM.ensure(ruleresult != null);

									// create link
									ruleresult.getMatches().add(match);

									fujaba__Success = true;
								} catch (JavaSDMException fujaba__InternalException) {
									fujaba__Success = false;
								}

							} else {

							}

							fujaba__Success = true;
						} catch (JavaSDMException fujaba__InternalException) {
							fujaba__Success = false;
						}
					}
					JavaSDM.ensure(fujaba__Success);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'set success'
		try {
			fujaba__Success = false;

			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link matches from ruleresult to match
			fujaba__Success = false;

			fujaba__IterRuleresultToMatch = ruleresult.getMatches().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterRuleresultToMatch.hasNext()) {
				try {
					match = (Match) fujaba__IterRuleresultToMatch.next();

					// check object match is really bound
					JavaSDM.ensure(match != null);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// assign attribute ruleresult
			ruleresult.setSuccess(true);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsAppropriateRuleResult isAppropriate_FWD_Node_4(Node blipModelNode) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsAppropriateRuleResult ruleresult = null;
		Match match = null;
		Iterator fujaba__IterBlipModelNodeToNameAttr = null;
		Attribute nameAttr = null;
		Node applicationNode = null;
		Iterator fujaba__IterRuleresultToMatch = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "isApplicable_FWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsAppropriateRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);

			// create link
			ruleresult.setPerformOperation(performOperation);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'test core match'
		try {
			fujaba__Success = false;

			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// bind object
			applicationNode = blipModelNode.getParentNode();

			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);

			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// iterate to-many link attribute from blipModelNode to nameAttr
			fujaba__Success = false;

			fujaba__IterBlipModelNodeToNameAttr = new ArrayList(
					blipModelNode.getAttribute()).iterator();

			while (fujaba__IterBlipModelNodeToNameAttr.hasNext()) {
				try {
					nameAttr = (Attribute) fujaba__IterBlipModelNodeToNameAttr
							.next();

					// check object nameAttr is really bound
					JavaSDM.ensure(nameAttr != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							blipModelNode.getName(), "Model") == 0);

					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(nameAttr.getName(),
							"name") == 0);

					// create object match
					match = TGGRuntimeFactory.eINSTANCE.createMatch();

					// statement node 'bookkeeping with generic isAppropriate method'
					fujaba__Success = this.isAppropriate_FWD(match,
							applicationNode, blipModelNode, nameAttr);
					if (fujaba__Success) {
						// story node 'Add match to rule result'
						try {
							fujaba__Success = false;

							// check object match is really bound
							JavaSDM.ensure(match != null);
							// check object ruleresult is really bound
							JavaSDM.ensure(ruleresult != null);

							// create link
							ruleresult.getMatches().add(match);

							fujaba__Success = true;
						} catch (JavaSDMException fujaba__InternalException) {
							fujaba__Success = false;
						}

					} else {

					}

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'set success'
		try {
			fujaba__Success = false;

			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link matches from ruleresult to match
			fujaba__Success = false;

			fujaba__IterRuleresultToMatch = ruleresult.getMatches().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterRuleresultToMatch.hasNext()) {
				try {
					match = (Match) fujaba__IterRuleresultToMatch.next();

					// check object match is really bound
					JavaSDM.ensure(match != null);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// assign attribute ruleresult
			ruleresult.setSuccess(true);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsAppropriateRuleResult isAppropriate_FWD_Attribute_5(
			Attribute nameAttr) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsAppropriateRuleResult ruleresult = null;
		Match match = null;
		Node applicationNode = null;
		Node blipModelNode = null;
		Iterator fujaba__IterRuleresultToMatch = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "isApplicable_FWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsAppropriateRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);

			// create link
			ruleresult.setPerformOperation(performOperation);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'test core match'
		try {
			fujaba__Success = false;

			// check object nameAttr is really bound
			JavaSDM.ensure(nameAttr != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// bind object
			blipModelNode = nameAttr.getNode();

			// check object blipModelNode is really bound
			JavaSDM.ensure(blipModelNode != null);

			// bind object
			applicationNode = blipModelNode.getParentNode();

			// check object applicationNode is really bound
			JavaSDM.ensure(applicationNode != null);

			// check isomorphic binding between objects blipModelNode and applicationNode 
			JavaSDM.ensure(!blipModelNode.equals(applicationNode));

			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(blipModelNode.getName(),
					"Model") == 0);

			// attribute condition
			JavaSDM.ensure(JavaSDM.stringCompare(nameAttr.getName(), "name") == 0);

			// create object match
			match = TGGRuntimeFactory.eINSTANCE.createMatch();

			// statement node 'bookkeeping with generic isAppropriate method'
			fujaba__Success = this.isAppropriate_FWD(match, applicationNode,
					blipModelNode, nameAttr);
			if (fujaba__Success) {
				// story node 'Add match to rule result'
				try {
					fujaba__Success = false;

					// check object match is really bound
					JavaSDM.ensure(match != null);
					// check object ruleresult is really bound
					JavaSDM.ensure(ruleresult != null);

					// create link
					ruleresult.getMatches().add(match);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}

			} else {

			}

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'set success'
		try {
			fujaba__Success = false;

			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link matches from ruleresult to match
			fujaba__Success = false;

			fujaba__IterRuleresultToMatch = ruleresult.getMatches().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterRuleresultToMatch.hasNext()) {
				try {
					match = (Match) fujaba__IterRuleresultToMatch.next();

					// check object match is really bound
					JavaSDM.ensure(match != null);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// assign attribute ruleresult
			ruleresult.setSuccess(true);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsAppropriateRuleResult isAppropriate_BWD_BlipApplication_1(
			BlipApplication application) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsAppropriateRuleResult ruleresult = null;
		Match match = null;
		Iterator fujaba__IterApplicationToBlipModel = null;
		BlipModel blipModel = null;
		Iterator fujaba__IterRuleresultToMatch = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "isApplicable_BWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsAppropriateRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);

			// create link
			ruleresult.setPerformOperation(performOperation);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'test core match'
		try {
			fujaba__Success = false;

			// check object application is really bound
			JavaSDM.ensure(application != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link models from application to blipModel
			fujaba__Success = false;

			fujaba__IterApplicationToBlipModel = new ArrayList(
					application.getModels()).iterator();

			while (fujaba__IterApplicationToBlipModel.hasNext()) {
				try {
					blipModel = (BlipModel) fujaba__IterApplicationToBlipModel
							.next();

					// check object blipModel is really bound
					JavaSDM.ensure(blipModel != null);
					// create object match
					match = TGGRuntimeFactory.eINSTANCE.createMatch();

					// statement node 'bookkeeping with generic isAppropriate method'
					fujaba__Success = this.isAppropriate_BWD(match,
							application, blipModel);
					if (fujaba__Success) {
						// story node 'Add match to rule result'
						try {
							fujaba__Success = false;

							// check object match is really bound
							JavaSDM.ensure(match != null);
							// check object ruleresult is really bound
							JavaSDM.ensure(ruleresult != null);

							// create link
							ruleresult.getMatches().add(match);

							fujaba__Success = true;
						} catch (JavaSDMException fujaba__InternalException) {
							fujaba__Success = false;
						}

					} else {

					}

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'set success'
		try {
			fujaba__Success = false;

			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link matches from ruleresult to match
			fujaba__Success = false;

			fujaba__IterRuleresultToMatch = ruleresult.getMatches().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterRuleresultToMatch.hasNext()) {
				try {
					match = (Match) fujaba__IterRuleresultToMatch.next();

					// check object match is really bound
					JavaSDM.ensure(match != null);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// assign attribute ruleresult
			ruleresult.setSuccess(true);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IsAppropriateRuleResult isAppropriate_BWD_BlipModel_1(
			BlipModel blipModel) {
		boolean fujaba__Success = false;
		Object _TmpObject = null;
		EClass eClass = null;
		Iterator fujaba__IterEClassToPerformOperation = null;
		EOperation performOperation = null;
		IsAppropriateRuleResult ruleresult = null;
		Match match = null;
		BlipApplication application = null;
		Iterator fujaba__IterRuleresultToMatch = null;

		// story node 'prepare return value'
		try {
			fujaba__Success = false;

			_TmpObject = (this.eClass());

			// ensure correct type and really bound of object eClass
			JavaSDM.ensure(_TmpObject instanceof EClass);
			eClass = (EClass) _TmpObject;
			// iterate to-many link eOperations from eClass to performOperation
			fujaba__Success = false;

			fujaba__IterEClassToPerformOperation = eClass.getEOperations()
					.iterator();

			while (!(fujaba__Success)
					&& fujaba__IterEClassToPerformOperation.hasNext()) {
				try {
					performOperation = (EOperation) fujaba__IterEClassToPerformOperation
							.next();

					// check object performOperation is really bound
					JavaSDM.ensure(performOperation != null);
					// attribute condition
					JavaSDM.ensure(JavaSDM.stringCompare(
							performOperation.getName(), "isApplicable_BWD") == 0);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// create object ruleresult
			ruleresult = TGGRuntimeFactory.eINSTANCE
					.createIsAppropriateRuleResult();

			// assign attribute ruleresult
			ruleresult.setSuccess(false);

			// create link
			ruleresult.setPerformOperation(performOperation);

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'test core match'
		try {
			fujaba__Success = false;

			// check object blipModel is really bound
			JavaSDM.ensure(blipModel != null);
			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// bind object
			application = blipModel.eContainer() instanceof BlipApplication ? (BlipApplication) blipModel
					.eContainer() : null;

			// check object application is really bound
			JavaSDM.ensure(application != null);

			// check if contained via correct reference
			JavaSDM.ensure(application.getModels().contains(blipModel));

			// create object match
			match = TGGRuntimeFactory.eINSTANCE.createMatch();

			// statement node 'bookkeeping with generic isAppropriate method'
			fujaba__Success = this.isAppropriate_BWD(match, application,
					blipModel);
			if (fujaba__Success) {
				// story node 'Add match to rule result'
				try {
					fujaba__Success = false;

					// check object match is really bound
					JavaSDM.ensure(match != null);
					// check object ruleresult is really bound
					JavaSDM.ensure(ruleresult != null);

					// create link
					ruleresult.getMatches().add(match);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}

			} else {

			}

			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		// story node 'set success'
		try {
			fujaba__Success = false;

			// check object ruleresult is really bound
			JavaSDM.ensure(ruleresult != null);
			// iterate to-many link matches from ruleresult to match
			fujaba__Success = false;

			fujaba__IterRuleresultToMatch = ruleresult.getMatches().iterator();

			while (!(fujaba__Success)
					&& fujaba__IterRuleresultToMatch.hasNext()) {
				try {
					match = (Match) fujaba__IterRuleresultToMatch.next();

					// check object match is really bound
					JavaSDM.ensure(match != null);

					fujaba__Success = true;
				} catch (JavaSDMException fujaba__InternalException) {
					fujaba__Success = false;
				}
			}
			JavaSDM.ensure(fujaba__Success);
			// assign attribute ruleresult
			ruleresult.setSuccess(true);
			fujaba__Success = true;
		} catch (JavaSDMException fujaba__InternalException) {
			fujaba__Success = false;
		}

		return ruleresult;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments)
			throws InvocationTargetException {
		switch (operationID) {
		case RulesPackage.MMODEL_TO_MODEL_RULE___PERFORM_FWD__ISAPPLICABLEMATCH:
			return perform_FWD((IsApplicableMatch) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_FWD__MATCH_NODE_NODE_ATTRIBUTE:
			return isAppropriate_FWD((Match) arguments.get(0),
					(Node) arguments.get(1), (Node) arguments.get(2),
					(Attribute) arguments.get(3));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPLICABLE_FWD__MATCH:
			return isApplicable_FWD((Match) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___PERFORM_BWD__ISAPPLICABLEMATCH:
			return perform_BWD((IsApplicableMatch) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_BWD__MATCH_BLIPAPPLICATION_BLIPMODEL:
			return isAppropriate_BWD((Match) arguments.get(0),
					(BlipApplication) arguments.get(1),
					(BlipModel) arguments.get(2));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPLICABLE_BWD__MATCH:
			return isApplicable_BWD((Match) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_FWD_NODE_3__NODE:
			return isAppropriate_FWD_Node_3((Node) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_FWD_NODE_4__NODE:
			return isAppropriate_FWD_Node_4((Node) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_FWD_ATTRIBUTE_5__ATTRIBUTE:
			return isAppropriate_FWD_Attribute_5((Attribute) arguments.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_BWD_BLIP_APPLICATION_1__BLIPAPPLICATION:
			return isAppropriate_BWD_BlipApplication_1((BlipApplication) arguments
					.get(0));
		case RulesPackage.MMODEL_TO_MODEL_RULE___IS_APPROPRIATE_BWD_BLIP_MODEL_1__BLIPMODEL:
			return isAppropriate_BWD_BlipModel_1((BlipModel) arguments.get(0));
		}
		return super.eInvoke(operationID, arguments);
	}

} //MModelToModelRuleImpl
